﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Touch2Like.DAL;
using Touch2Like.Model;
using Touch2Like.SharedLibrary;

namespace Touch2Like.Web.Product
{
    public partial class OrderConfirmation : System.Web.UI.Page
    {
//        protected void Page_Load(object sender, EventArgs e)
//        {
//            if (!IsPostBack)
//            {
//                if (WebUtility.UserGUID == "0")
//                {

//                }
//                else
//                {
//                    Touch2Like.DAL.UserDAL user = new Touch2Like.DAL.UserDAL();
//                    UserInfo userInfo = user.GetUserByUserGuid(WebUtility.UserGUID);

//                    if (userInfo != null)
//                    {
//                    }
//                }

//                OrderDAL order = new OrderDAL();
//                OrderInfo orderInfo = order.GetByID(Convert.ToInt32(Utility.Encryption.Decrypt(Request["OrderID"])));

//                if (orderInfo != null)
//                {
//                    lb_TotalPrice.Text = Utility.GetPriceString(orderInfo.TotalPrice);

//                    ShoppingCartDAL cart = new ShoppingCartDAL();

//                    Repeater_Cart.DataSource = cart.GetByOrderNumber(orderInfo.OrderNumber);
//                    Repeater_Cart.DataBind();
//                }
//            }
//            if (PreviousPage != null && PreviousPage.IsCrossPagePostBack)
//            {
//                CheckBox cb_CreateAccount = PreviousPage.Master.FindControl("maincontent").FindControl("cb_CreateAccount") as CheckBox;
//                TextBox tb_Password = PreviousPage.Master.FindControl("maincontent").FindControl("tb_Password") as TextBox;
//                TextBox tb_Password1 = PreviousPage.Master.FindControl("maincontent").FindControl("tb_Password1") as TextBox;
//                TextBox tb_Email = PreviousPage.Master.FindControl("maincontent").FindControl("tb_Email") as TextBox;

//                TextBox tb_FirstName = PreviousPage.Master.FindControl("maincontent").FindControl("tb_FirstName") as TextBox;
//                TextBox tb_MI = PreviousPage.Master.FindControl("maincontent").FindControl("tb_MI") as TextBox;
//                TextBox tb_LastName = PreviousPage.Master.FindControl("maincontent").FindControl("tb_LastName") as TextBox;
//                TextBox tb_AddressLine1 = PreviousPage.Master.FindControl("maincontent").FindControl("tb_AddressLine1") as TextBox;
//                TextBox tb_AddressLine2 = PreviousPage.Master.FindControl("maincontent").FindControl("tb_AddressLine2") as TextBox;
//                TextBox tb_City = PreviousPage.Master.FindControl("maincontent").FindControl("tb_City") as TextBox;
//                DropDownList ddl_State = PreviousPage.Master.FindControl("maincontent").FindControl("ddl_State") as DropDownList;
//                TextBox tb_Zip = PreviousPage.Master.FindControl("maincontent").FindControl("tb_Zip") as TextBox;
//                TextBox tb_Phone = PreviousPage.Master.FindControl("maincontent").FindControl("tb_Phone") as TextBox;
//                RadioButtonList rbl_Shipping = PreviousPage.Master.FindControl("maincontent").FindControl("rbl_Shipping") as RadioButtonList;
//                RadioButtonList rbl_PaymentType = PreviousPage.Master.FindControl("maincontent").FindControl("rbl_PaymentType") as RadioButtonList;
//                DropDownList ddl_CreditCardType = PreviousPage.Master.FindControl("maincontent").FindControl("ddl_CreditCardType") as DropDownList;
//                TextBox tb_CreditCardNumber = PreviousPage.Master.FindControl("maincontent").FindControl("tb_CreditCardNumber") as TextBox;
//                DropDownList ddl_Month = PreviousPage.Master.FindControl("maincontent").FindControl("ddl_Month") as DropDownList;
//                DropDownList ddl_Year = PreviousPage.Master.FindControl("maincontent").FindControl("ddl_Year") as DropDownList;
//                TextBox tb_CSV = PreviousPage.Master.FindControl("maincontent").FindControl("tb_CSV") as TextBox;

//                TextBox tb_SFirstName = PreviousPage.Master.FindControl("maincontent").FindControl("tb_SFirstName") as TextBox;
//                TextBox tb_SMI = PreviousPage.Master.FindControl("maincontent").FindControl("tb_SMI") as TextBox;
//                TextBox tb_SLastName = PreviousPage.Master.FindControl("maincontent").FindControl("tb_SLastName") as TextBox;
//                TextBox tb_SAddressLine1 = PreviousPage.Master.FindControl("maincontent").FindControl("tb_SAddressLine1") as TextBox;
//                TextBox tb_SAddressLine2 = PreviousPage.Master.FindControl("maincontent").FindControl("tb_SAddressLine2") as TextBox;
//                TextBox tb_SCity = PreviousPage.Master.FindControl("maincontent").FindControl("tb_SCity") as TextBox;
//                DropDownList ddl_SState = PreviousPage.Master.FindControl("maincontent").FindControl("ddl_SState") as DropDownList;
//                TextBox tb_SZip = PreviousPage.Master.FindControl("maincontent").FindControl("tb_SZip") as TextBox;

//                if (WebUtility.UserGUID == "0")
//                {
//                    if (cb_CreateAccount.Checked)
//                    {
//                        if (tb_Password.Text.Trim() != "" && tb_Password.Text.Trim() == tb_Password1.Text.Trim())
//                        {
//                            UserDAL user = new UserDAL();
//                            UserInfo userInfo = new UserInfo();

//                            userInfo.UserName = tb_Email.Text.Trim();
//                            userInfo.Email = tb_Email.Text.Trim();
//                            userInfo.Password = Utility.Encryption.Encrypt(tb_Password.Text.Trim());
//                            userInfo.UserGuid = Guid.NewGuid().ToString();
//                            WebUtility.UserGUID = userInfo.UserGuid;
//                            user.UpdateUser(userInfo, GlobalManager.ActionPerformed.Add);
//                        }
//                        else
//                        {
//                            return;
//                        }
//                    }
//                    else
//                    {
//                        return;
//                    }
//                }

//                lb_FirstName.Text = tb_FirstName.Text.Trim();
//                lb_LastName.Text = tb_LastName.Text.Trim();
//                lb_Email.Text = tb_Email.Text.Trim();
//                lb_BillingAddress.Text = tb_AddressLine1.Text.Trim() + " " + tb_AddressLine2.Text.Trim() + " " + tb_City.Text.Trim() + " " + ddl_State.SelectedValue + " " + tb_Zip.Text.Trim() + " " + tb_Phone.Text.Trim();
//                lb_ShippingAddress.Text = tb_SAddressLine1.Text.Trim() + " " + tb_SAddressLine2.Text.Trim() + " " + tb_SCity.Text.Trim() + " " + ddl_SState.SelectedValue + " " + tb_SZip.Text.Trim();
//                lb_CreditCard.Text = ddl_CreditCardType.SelectedValue;



//                OrderDAL order = new OrderDAL();
//                OrderInfo orderInfo = order.GetByID(Convert.ToInt32(Utility.Encryption.Decrypt(Request["OrderID"])));

//                if (orderInfo != null)
//                {
//                    lb_TotalPrice.Text = Utility.GetPriceString(orderInfo.TotalPrice + Convert.ToDecimal(rbl_Shipping.SelectedValue));

//                    ShoppingCartDAL cart = new ShoppingCartDAL();

//                    Repeater_Cart.DataSource = cart.GetByOrderNumber(orderInfo.OrderNumber);
//                    Repeater_Cart.DataBind();
//                }
//            }
//        }

//        public string GetSubTotal(object price, object count)
//        {
//            if (DataHelper.GetDouble(price) != null && DataHelper.GetInt(count) != null)
//            {
//                return Utility.GetPriceString(DataHelper.GetDouble(price).Value * DataHelper.GetInt(count).Value);
//            }

//            return "0.00";
//        }
    }
}